home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
001
/
pibt40s1.arc
/
GETDOWNL.MOD
< prev
next >
Wrap
Text File
|
1987-09-08
|
7KB
|
205 lines
(*----------------------------------------------------------------------*)
(* Get_Download_Protocol --- Get File Transfer Protocol *)
(*----------------------------------------------------------------------*)
FUNCTION Get_Download_Protocol : Transfer_Type ;
(*----------------------------------------------------------------------*)
(* *)
(* Function: Get_Download_Protocol *)
(* *)
(* Purpose: Gets file name and transfer protocol for download. *)
(* *)
(* Calling Sequence: *)
(* *)
(* Transtyp := Get_Download_Protocol: Transfer_Type; *)
(* *)
(* Remarks: *)
(* *)
(* Calls: KeyPressed *)
(* Async_Send *)
(* Async_Receive *)
(* *)
(*----------------------------------------------------------------------*)
CONST
Ascii_Quit_Item = 4;
VAR
Transfer_Kind : Transfer_Type;
Ascii_Menu : Menu_Type;
I : INTEGER;
Pacing_String : STRING[1];
OK_File_Name : BOOLEAN;
Flag : BOOLEAN;
IY : INTEGER;
AFile : FILE;
(*----------------------------------------------------------------------*)
FUNCTION Yes_No_String( B: BOOLEAN ) : AnyStr;
BEGIN (* Yes_No_String *)
IF B THEN
Yes_No_String := 'YES'
ELSE
Yes_No_String := 'NO';
END (* Yes_No_String *);
(*----------------------------------------------------------------------*)
PROCEDURE Get_Ascii_Parameters;
VAR
Ascii_Done : BOOLEAN;
I : INTEGER;
J : INTEGER;
Local_Save : Saved_Screen_Ptr;
BEGIN (* Get_Ascii_Parameters *)
Make_A_Menu( Ascii_Menu, Ascii_Quit_Item, 3, 10, 50, 21, Ascii_Quit_Item,
'Ascii transfer parameters: ',
';;;Perform transfer;', TRUE );
Ascii_Done := FALSE;
REPEAT
FOR I := 1 TO ( Ascii_Quit_Item - 1 ) DO
WITH Ascii_Menu.Menu_Entries[I] DO
CASE I OF
1: Menu_Item_Text := 'a) Ctrl-Z marks end of file (now ' +
Yes_No_String( Ascii_Use_CtrlZ ) + ')';
2: Menu_Item_Text := 'b) Display text transferred (now ' +
Yes_No_String( Ascii_Show_Text ) + ')';
3: Menu_Item_Text := 'c) Translate incoming text (now ' +
Yes_No_String( Ascii_Translate ) + ')';
END (* CASE *);
Menu_Display_Choices( Ascii_Menu );
I := Menu_Get_Choice( Ascii_Menu , Dont_Erase_Menu );
CASE I OF
1 : Ascii_Use_CtrlZ := NOT Ascii_Use_CtrlZ;
2 : Ascii_Show_Text := NOT Ascii_Show_Text;
3 : Ascii_Translate := NOT Ascii_Translate;
ELSE
Ascii_Done := TRUE;
END (* CASE *);
UNTIL ( Ascii_Done );
(* Remove this window *)
Restore_Screen( Saved_Screen );
Reset_Global_Colors;
END (* Get_Ascii_Parameters *);
(*----------------------------------------------------------------------*)
BEGIN (* Get_Download_Protocol *)
(* Copy keyboard data before we screw *)
(* it up so we can get file name *)
Saved_Kbd_File_Name := Keyboard_Line;
(* Display menu of transfer types *)
(* and get transfer kind. *)
Display_Transfer_Types( 'receive' , Transfer_Kind );
(* Get file name to use if not *)
(* batch transfer *)
Ok_File_Name := FALSE;
FileName[0] := #0;
IF Single_File_Protocol[Transfer_Kind] THEN
BEGIN
IF Auto_Find_FileNames THEN
Get_Auto_File_Name( Saved_Kbd_File_Name , FileName );
REPEAT
FOR I := 18 TO 20 DO
BEGIN
GoToXY( 1 , I );
ClrEol;
END;
GoToXY( 2 , 18 );
WRITE('Enter Filename.Ext: ');
GoToXY( 2 , 19 );
WRITE('>');
Read_Edited_String(FileName);
WRITELN;
IF ( POS( ':' , FileName ) = 0 ) AND
( POS( '\' , FileName ) = 0 ) THEN
Saved_Kbd_File_Name := Download_Dir_Path + FileName
ELSE
Saved_Kbd_File_Name := FileName;
ASSIGN(AFile,Saved_Kbd_File_Name);
(*$I- *)
RESET( AFile );
(*$I+ *)
IF Int24Result <> 0 THEN
OK_File_Name := TRUE
ELSE
BEGIN
OK_File_Name := YesNo( Saved_Kbd_File_Name + ' exists, overwrite (Y/N) ? ');
(*$I-*)
CLOSE( AFile );
(*$I+*)
END;
UNTIL( OK_File_Name );
ASSIGN( AFile, Saved_Kbd_File_Name );
(*$I- *)
REWRITE( AFile );
(*$I+ *)
IF Int24Result <> 0 THEN
BEGIN
Transfer_Kind := None;
WRITE('*** Can''t open file, receive cancelled ***');
DELAY( Two_Second_Delay );
END;
(*$I-*)
CLOSE( AFile );
(*$I+*)
I := INT24Result;
END (* Get file name *);
(* Remove this window *)
Restore_Screen( Saved_Screen );
Reset_Global_Colors;
Use_Time_Sent := Use_Block_Zero;
IF ( Transfer_Kind = Ascii ) THEN
Get_Ascii_Parameters;
(* Return transfer protocol type *)
Get_Download_Protocol := Transfer_Kind;
END (* Get_Download_Protocol *);